<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../../js/jquery-3.4.1.js"></script>
</head>
<body>

</body>
<script>

    $(() => {
        test1();
        testRepeat();
    });

    function test1() {
        let arr = new Array();
        for(let i = 0; i < 10; i++) {
            arr.push({
                id: i,
                name: 's' + i
            });
        }
        console.log(JSON.stringify(arr));
    }

    function testRepeat() {
        let arr1 = new Array();
        let arr2 = new Array();

        arr1.push('s1', 's2', 's3');
        arr2.push({
            name: 's1',
        }, {
            name: 's2'
        }, {
            name: 's3'
        });
        for(let i = 0; i < arr1.length - 1; i++) {
            for(let j = i + 1; j < arr1.length; j++) {
                if(arr1[i] === arr1[j]) {
                    console.log('arr1存在重复数据');
                    break;
                }
            }
        }

        for(let i = 0; i < arr2.length - 1; i++) {
            for(let j = i + 1; j < arr2.length; j++) {
                if(arr2[i].name === arr2[j].name) {
                    console.log('arr2存在重复数据');
                    break;
                }
            }
        }
    }

</script>
</html>